package cn.hdmis.action;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import cn.hdmis.entity.ClassRoom;
import cn.hdmis.service.ClassRoomService;

public class ClassRoomAction extends BaseAction {

	private static final long serialVersionUID = 2907697252997786809L;
	private ClassRoom room;
	private List<ClassRoom> roomList;
	private ClassRoomService roomService;
	
	public void setRoom(ClassRoom room) {
		this.room = room;
	}

	public ClassRoom getRoom() {
		return room;
	}
	
	public void setRoomList(List<ClassRoom> roomList) {
		this.roomList = roomList;
	}
	@JSON(name="rows")
	public List<ClassRoom> getRoomList() {
		return roomList;
	}
	@JSON(serialize=false)
	public ClassRoomService getRoomService() {
		return roomService;
	}

	public void setRoomService(ClassRoomService roomService) {
		this.roomService = roomService;
	}

	public String addClassRoom(){
		try {
			 roomService.addClassRoom(room);
		} catch (Exception e) {
			setMSG(MSG_FAILED); 
			logger.error(e.getMessage());
		}
		return "addSuccess";
	}
	public String loadClassRoom(){
		try {
			List<ClassRoom> list = roomService.getClassRoom();
			this.setRoomList(list);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return  "roomList";
	}

	
}
